# TODO 首页搜索操作

import time
from selenium import webdriver
from selenium.webdriver.common.by import By

# 1.打开ecshop演示
driver = webdriver.Chrome()
driver.get('https://ecshop.test2.shopex123.com')

# 2.定位首页并输入关键字--护肤品--定位搜索框并点击
driver.find_element(By.ID, 'keyword').send_keys('护肤品')
time.sleep(2)
driver.find_element(By.NAME, 'imageField').click()

# 3.关闭浏览器
time.sleep(2)
driver.quit()



# TODO 注册操作

import time
from selenium import webdriver
from selenium.webdriver.common.by import By

# 1.打开ecshop演示
driver = webdriver.Chrome()
driver.get('https://ecshop.test2.shopex123.com')

# 2.定位--免费注册--并点击
driver.find_element(By.LINK_TEXT, '[ 免费注册 ]').click()

# 3.定位--用户名输入框--并输入用户名'胖豆芽'
time.sleep(2)
driver.find_element(By.ID,'username').send_keys('胖豆芽')

# 4.定位--邮箱输入框--并输入邮箱名'646785211@qq.com'
time.sleep(2)
driver.find_element(By.ID,'email').send_keys('646785211@qq.com')

# 5.定位--密码输入框--并输入密码'Cq646785211'
time.sleep(2)
driver.find_element(By.ID,'password1').send_keys('Cq646785211')

# 6.定位--确认密码输入框--并输入密码'Cq646785211'
time.sleep(2)
driver.find_element(By.ID,'confirm_password').send_keys('Cq646785211')

# 7.定位--同意协议并注册--选项，并点击,,默认已勾选
# time.sleep(2)
# driver.find_element(By.NAME,'agreement').click()

# 8.定位--我已看过并接受《用户协议》--选项前勾选框，并点击
time.sleep(2)
driver.find_element(By.NAME,'Submit').click()

# 9.关闭浏览器
time.sleep(2)
driver.quit()



# TODO 登录操作

import time
from selenium import webdriver
from selenium.webdriver.common.by import By

# 1.打开ecshop演示
driver = webdriver.Chrome()
driver.get('https://ecshop.test2.shopex123.com')

# 2.定位首页并点击
driver.find_element(By.LINK_TEXT, '[ 请登录 ]').click()

# 3.定位--用户名输入框--并输入用户名'胖豆芽'
time.sleep(2)
driver.find_element(By.TAG_NAME, 'input').send_keys('胖豆芽')

# 4.定位--密码输入框--并输入密码'Cq646785211'
time.sleep(2)
driver.find_element(By.NAME, 'password').send_keys('Cq646785211')

# 5.定位--登录--选项，并点击
time.sleep(2)
driver.find_element(By.NAME,'submit').click()

# 6.关闭浏览器
time.sleep(2)
driver.quit()